package com.yangchao.webflux.repositories.convert;

import com.yangchao.webflux.damain.Person;
import io.r2dbc.spi.Row;
import org.slf4j.Logger;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;


/**
 *
 * 告诉Spring Data 怎么封装Book对象
 */
@ReadingConverter
public class PersonConverter implements Converter<Row, Person> {
     Logger logger = org.slf4j.LoggerFactory.getLogger(PersonConverter.class);
    @Override
    public Person convert(Row source) {
        return new Person(source.get("id", Integer.class),source.get("name", String.class),source.get("age", Integer.class));
    }
}